package com.ruoyi.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.SysPrizeManagement;
import com.ruoyi.system.mapper.SysPrizeManagementMapper;
import com.ruoyi.system.service.ISysPrizeManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author HP
 * @Date 2021/2/24
 * @Description TODO
 */
@Service
public class SysPrizeManagementServiceImpl implements ISysPrizeManagementService {
    @Autowired
    private SysPrizeManagementMapper sysPrizeManagementMapper;
    /*
    查询所有礼品信息
     */

    @Override
    public List<SysPrizeManagement> selectSysPrizeManagement(SysPrizeManagement sysPrizeManagement,Integer pageNum,Integer pageSize) {
        if (pageNum!=null&&pageSize!=null){
            PageHelper.startPage((pageNum / pageSize) + 1,pageSize);
        }
        List<SysPrizeManagement> sysPrizeManagements = sysPrizeManagementMapper.selectSysPrizeManagement(sysPrizeManagement);
        return sysPrizeManagements;
    }
    /*
      添加礼品信息
     */

    @Override
    public void saveSysPrizeManagement(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper.saveSysPrizeManagement(sysPrizeManagement);
    }
    /*
     删除礼品信息
    */

    @Override
    public void deleteSysPrizeManagement(int pid) {
        sysPrizeManagementMapper.deleteSysPrizeManagement(pid);
    }
    /*
    根据id查询
     */

    @Override
    public SysPrizeManagement selectById(int pid) {
        SysPrizeManagement sysPrizeManagement = sysPrizeManagementMapper.selectById(pid);
        return sysPrizeManagement;
    }
    /*
     修改礼品信息
    */

    @Override
    public void updateSysPrizeManagement(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper. updateSysPrizeManagement(sysPrizeManagement);
    }

    @Override
    public void updateByCounts(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper.updateByCounts(sysPrizeManagement);
    }

    /*
   删除奖品数量 添加对应的礼品数量
    */
    @Override
    public void saveByCounts(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper.saveByCounts(sysPrizeManagement);
    }

    @Override
    public void saveByCounts1(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper.saveByCounts1(sysPrizeManagement);
    }

    @Override
    public void updateByCounts1(SysPrizeManagement sysPrizeManagement) {
        sysPrizeManagementMapper.updateByCounts1(sysPrizeManagement);
    }


}
